package com.yuewen.mall.common.mallcacher;

import com.yuewenmall.common.baseentities.product.SearchRequestDataInfo;
import com.yuewenmall.common.utilities.CryptographyUtility;
import com.yuewenmall.common.utilities.JsonUtility;

import java.math.BigInteger;

/**
 * Created by liwei.b on 2016/6/30.
 */
public class ProductCacheKeyManager {
    private ProductCacheKeyManager() {
    }

    //全部库存信息 缓存key
    public static String getAllProductCompacityCacheKey() {
        return "com.yuewen.mall.allproductcompacity";
    }

    //全部库存信息缓存过期时间
    public static int getAllProductCompacityCacheTimeout() {
        return 3 * 60;//3min
    }

    //搜索结果 缓存key
    public static String getDoSearchCacheKey(SearchRequestDataInfo searchRequest) {
        return "com.yuewen.mall.search." + CryptographyUtility.MD5(JsonUtility.ToJsonString(searchRequest));
    }

    //搜索结果 缓存过期时间
    public static int getDoSearchCacheKeyTimeout() {
        return 3 * 60;//3min}
    }

    //缓存商品集的全部属性
    public static String getProductAttributesByProductSetIdCacheKey(BigInteger productSetId) {
        return "com.yuewen.mall.productattributes.productsetid." + productSetId;
    }

    //缓存商品集的全部属性 的超时时间
    public static int getProductAttributesByProductSetIdCacheKeyTimeout() {
        return 3 * 60;//3min}
    }

    //缓存全部商品，商品集信息的key
    public static String getAllProductCacheKey() {
        return "com.yuewen.mall.search.allproduct.";
    }

    //缓存全部商品 商品集key的过期时间
    public static int getAllProductCacheKeyTimeout() {
        return 3 * 60;//3min
    }

    //缓存完整商品，商品集信息的key
    public static String getFullProductCacheKey(BigInteger productSetId) {
        return "com.yuewen.mall.fullproduct.setid" + productSetId;
    }

    //缓存完整商品 商品集key的过期时间
    public static int getFullProductCacheKeyTimeout() {
        return 3 * 60;//3min
    }
}